#include "xml/xml_attributes.h"

namespace Tvimeg
{
	XMLAttributes::XMLAttributes(const char** attributes)
	{
		int index = 0;
		while (attributes[index])
		{
			const std::string key(attributes[index]);
			const std::string value(attributes[index + 1]);
			(*this)[key] = value;

			index += 2;
		}
	}

	const std::string& XMLAttributes::GetAttribute(const std::string& name) const
	{
		const const_iterator found = find(name);
		if (found != end())
		{
			return found->second;
		}
		else
		{
			static const std::string empty;
			return empty;
		}
	}

	bool XMLAttributes::HasAttribute(const std::string& name) const
	{
		return find(name) != end();
	}
}
